#ifndef MineCraftSceneGeometry_H
#define MineCraftSceneGeometry_H


#include <QtQuick3D/QQuick3DGeometry>
#include <QtQmlIntegration>

#include "minecraftscenedata.h"

//根据场景数据构建mc三角模型

class MineCraftSceneGeometry : public QQuick3DGeometry
{
    Q_OBJECT
    QML_ELEMENT
    Q_DISABLE_COPY(MineCraftSceneGeometry)

public:
    explicit MineCraftSceneGeometry(QQuick3DObject *parent = nullptr);

    MineCraftSceneData *scene() const;
    void setScene(MineCraftSceneData *newScene);

signals:
    void sceneChanged();

private:
    void rebuild();
    void buildScene(QByteArray& out);
    void validate();
private:
    MineCraftSceneData *m_scene = nullptr;
    QObject* m_connection = nullptr;
    Q_PROPERTY(MineCraftSceneData *scene READ scene WRITE setScene NOTIFY sceneChanged FINAL)
};



#endif
